export function getToken() {
  return localStorage.getItem('user')
    ? JSON.parse(localStorage.getItem('user') as string)?.userInfo?.token
    : '';
}

export function getIsLogin() {
  return localStorage.getItem('user')
    ? JSON.parse(localStorage.getItem('user') as string)?.userInfo?.isLogin
    : false;
}

export function getLoginUserId() {
  return localStorage.getItem('user')
    ? JSON.parse(localStorage.getItem('user') as string)?.userInfo?.userMsg?.userId
    : '';
}

export function getEnterpriseId() {
  return localStorage.getItem('user')
    ? JSON.parse(localStorage.getItem('user') as string)?.userInfo?.userMsg?.enterpriseId
    : '';
}

export function getRoleKeys(): string[] {
  return localStorage.getItem('user')
    ? JSON.parse(localStorage.getItem('user') as string)?.userInfo?.userMsg?.roles?.map(
        (item: any) => item.roleKey
      )
    : [];
}
